<?php

/**
 * Created by PhpStorm.
 * User: isaac
 * Date: 15/7/22
 * Time: 下午3:53
 */
class SMS {

    private $_smsConfig = null;
    private $_channel = 'luosimao';
    private $_sign = null;
    private $_apiURL = null;
    private $_apiKey = null;

    public function __construct() {

        $this->_smsConfig = require_once('config/sms.php');
        $this->_sign = $this->_smsConfig[$this->_channel]['sign'];
        $this->_apiURL = $this->_smsConfig[$this->_channel]['api_url'];
        $this->_apiKey = $this->_smsConfig[$this->_channel]['api_key'];
    }

    public function send($mobile, $message) {

        $params = array('mobile' => $mobile, 'message' => $message . $this->_sign);
        $opts = array(CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => $this->_apiKey);

        return Curl::post($this->_apiURL, $params, array(), $opts);
    }
}